/*
 * Copyright © 2022-now 尛飛俠（Denvie） All rights reserved.
 */

package cn.denvie.springcloud.order.config;

import feign.Logger;
import feign.Request;
import feign.Util;
import feign.auth.BasicAuthRequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * FeignConfig。
 *
 * @author Denvie
 * @date 2022/3/30
 * @since 1.0.0
 */
@Configuration
public class FeignConfig {
    /**
     * Feign 日志级别全局配置，如：NONE、BASIC、HEADERS、FULL
     */
    @Bean
    Logger.Level feignLoggerLevel() {
        return Logger.Level.BASIC;
    }

    /**
     * 配置请求超时时间。
     */
    @Bean
    Request.Options options() {
        return new Request.Options(5L, TimeUnit.SECONDS, 5L, TimeUnit.SECONDS, true);
    }

    /**
     * 配置基本的用户名密码授权。
     */
    @Bean
    BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
        return new BasicAuthRequestInterceptor("root", "123456", Util.UTF_8);
    }
}
